﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading.Tasks;

namespace CodeBook
{
    public class NotesEntity
    {

        private string _typeName;
        private string _title;
        private string _target;
        private string _account;
        private string _password;
        private string _remarks;
        private string _key;
        /// <summary>
        /// 备注类型
        /// </summary>
        public string typeName
        {
            get
            {
                if (string.IsNullOrEmpty(_typeName))
                {
                    return "";
                }
                return _typeName;
            }
            set { _typeName = value; }
        }
        /// <summary>
        /// 标题
        /// </summary>
        public string title
        {
            get
            {
                if (string.IsNullOrEmpty(_title))
                {
                    return "";
                }
                return _title;
            }
            set { _title = value; }
        }
        /// <summary>
        /// 目标地址
        /// </summary>
        public string target
        {
            get
            {
                if (string.IsNullOrEmpty(_target))
                {
                    return "";
                }
                return _target;
            }
            set { _target = value; }
        }
        /// <summary>
        /// 账号
        /// </summary>
        public string account
        {
            get
            {
                if (string.IsNullOrEmpty(_account))
                {
                    return "";
                }
                return _account;
            }
            set { _account = value; }
        }
        /// <summary>
        /// 密码
        /// </summary>
        public string password
        {
            get
            {
                if (string.IsNullOrEmpty(_password))
                {
                    return "";
                }
                return _password;
            }
            set { _password = value; }
        }
        /// <summary>
        /// 备注
        /// </summary>
        public string remarks
        {
            get
            {
                if (string.IsNullOrEmpty(_remarks))
                {
                    return "";
                }
                return _remarks;
            }
            set { _remarks = value; }
        }
        /// <summary>
        /// 唯一识别码
        /// </summary>
        public string key
        {
            get
            {
                if (string.IsNullOrEmpty(_key))
                {
                    return "";
                }
                return _key;
            }
            set { _key = value; }
        }
        //深拷贝
        public NotesEntity DeepCopy()
        {
            using (MemoryStream ms = new MemoryStream())
            {
                BinaryFormatter formatter = new BinaryFormatter();
                formatter.Serialize(ms, this);
                ms.Position = 0;
                return (NotesEntity)formatter.Deserialize(ms);
            }
        }
        // 使用 MemberwiseClone 进行浅拷贝
        public NotesEntity ShallowClone()
        {
            return (NotesEntity)this.MemberwiseClone();
        }
    }
}
